// 栈
class Stack {
  constructor() {
    this.stack = [];
    this.top = 0;
  }
  push(ele) {
    this.stack[this.top++] = ele;
  }
  pop() {
    return this.stack[--this.top];
  }
  peak() {
    if (this.top > 0) return this.stack[this.top - 1];
    else return 'empty';
  }
  length() {
    return this.top;
  }
  clear() {
    this.stack = [];
    this.top = 0;
  }
}


const str = '1001'

function isPalindrome(word) {
  const stack = new Stack();
  for (let i = 0; i < word.length; i ++) {
    stack.push(word[i]);
  }
  let rword = '';
  while(stack.length() > 0) {
    rword += stack.pop();
  }
  return word === rword;
}

console.log(isPalindrome(str));